# -*- coding: utf-8 -*-
from datetime import timedelta

from odoo import models, fields, api


class ViewEmployeeCalendarWizard(models.TransientModel):
    _name = 'view.employee.calendar.wizard'
    month_time_start=fields.Date()
    month_time_end = fields.Date()
    def action_confirm(self):
        date=self.month_time_start
        employees=self.env['hr.employee']
        employee_ids=self.env['hr.employee'].search([])
        print(date)
        while date <= self.month_time_end:
            print (date)
            if date.weekday() in (0,1,2,3,4):
                for employee_id in employee_ids:
                    if employee_id not in employees:
                        calendar=employee_id.get_current_calendar_id(date)
                        if not calendar:
                            employees|=employee_id
            date = date + timedelta(days=1)

        return {'type': 'ir.actions.act_window',
                'res_model': 'hr.employee',
                'name': u'员工',
                'view_mode': 'tree',
                'domain': [('id', 'in', employees.ids)],
                'target': 'self',
                }

